﻿<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>资料库管理</title>
    <meta name="viewport" content="initial-scale=1, maximum-scale=1">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    
    <link rel="stylesheet" href="//g.alicdn.com/msui/sm/0.5.8/css/sm.min.css">
    <link rel="stylesheet" href="//g.alicdn.com/msui/sm/0.5.8/css/sm-extend.min.css">

    <style type="text/css">

        .ms-controller, [ms-controller] {
            display: none;
        }
        .ui-list > li {
            margin: 3px;
        }

        .tab-item {
            border-right: 1px solid #ebebeb;
        }

            .tab-item:last-child {
                border-right:0px;
            }
        .tab-label {
            display: block;
            font-size: .7rem;
            position: relative;
        }
        .item-title {
            -webkit-box-flex: 1;
        }
    </style>
</head>
<body ms-controller="wdlist">
    <div class="page page-current" id="pageindex1">

        <nav class="bar bar-tab" style="border-top: 1px solid #ebebeb; background-color:#ffffff;">
            <a class="tab-item external active" onclick="tzurl(1)">
                <!--<span class="icon icon-home"></span>-->
                <span class="tab-label" >企业知识库</span>
            </a>
            <a class="tab-item external" onclick="tzurl(2)" >
                <!--<span class="icon icon-me"></span>-->
                <span class="tab-label" >个人文档</span>
            </a>
            <a class="tab-item external" onclick="tzurl(3)" >
                <!--<span class="icon icon-star"></span>-->
                <span class="tab-label" >我的收藏</span>
            </a>
            <a class="tab-item external" onclick="scwj()">
                <!--<span class="icon icon-up"></span>-->
                <span class="tab-label" >上传文件</span>
            </a>
            <input type="file" style="display:none;" id="file" onchange="UploadLoad()">
        </nav>
        <div class="content infinite-scroll infinite-scroll-bottom" data-distance="50">
            <p style="margin:5px;" id="path"></p>
            <div class="list-block" style="margin:0;">
                <!--<ul class="ui-list">
                    <li class="ui-border-t" ms-repeat-el="wjjData" ms-on-tap="vieww(el)" style="padding: 5px;">
                        <div style="padding-right:10px">
                            <img style="height:40px;width:40px" src="../Images/qywd/file1.png" />
                        </div>
                        <div class="ui-list-info">
                            <h4>{{el.Name}}</h4>
                        </div>
                    </li>
                    <li class="ui-border-t" ms-repeat-el="wjData" style="padding: 5px;">

                        <div style="padding-right:10px" ms-on-tap="viewwxx(el)">
                            <img ms-on-click="fdtp(this)" class="mall_pcp" style="height:40px;width:40px" ms-if="ComFunJS.xstp(el.FileExtendName)" ms-attr-src="'/ViewV5/Base/DownFile.aspx?fileId='+el.ID" />
                            <img style="height:40px;width:40px" ms-if="!ComFunJS.xstp(el.FileExtendName)" ms-attr-src="/View_Mobile/Images/qywd/{{el.FileExtendName}}.png" onerror="javascript: this.src = '/View_Mobile/Images/qywd/file.png'" />
                        </div>
                        <div class="ui-list-info" ms-on-tap="viewwxx(el)">
                            <h4 class="ui-nowrap">{{el.Name}}.{{el.FileExtendName}}</h4>
                        </div>
                        <div>
                            <a ms-attr-href="'/ViewV5/Base/DownFile.aspx?MD5='+el.FileMD5" class="external">
                                <img style="height: 40px; width: 40px; float: right; padding: 10px;" src="/View_Mobile/Images/down.png" />
                            </a>
                        </div>

                    </li>
                </ul>-->
                <div ms-if="no" style="text-align: center; position: absolute; top: 0; right: 0; bottom: 0; left: 0; overflow: auto;">
                    <img src="/View_Mobile/Images/notice.png" style="padding-top:100px" />
                    <p style=" color: #bbb;">无文件</p>
                </div>
                <ul>
                    <li class="item-content " ms-repeat-el="wjjData" ms-on-tap="vieww(el)" style="height: 60px;">
                        <div class="item-media" style="height:40px;padding:0;"><img style="height:40px;width:40px" src="/View_Mobile/Images/qywd/file1.png" /></div>
                        <div class="item-inner" style="height: 40px; padding: 0;">
                            <div class="item-title">{{el.Name}}</div>
                        </div>
                    </li>
                </ul>
                <ul>
                    <li class="item-content " ms-repeat-el="wjData" style="height: 60px;" >
                        <div class="item-media" style="height:40px">
                            <img ms-on-click="fdtp(this)" class="mall_pcp" style="height:40px;width:40px" ms-if="ComFunJS.xstp(el.FileExtendName)" ms-attr-src="'/ViewV5/Base/DownFile.aspx?fileId='+el.ID" />
                            <img style="height:40px;width:40px" ms-if="!ComFunJS.xstp(el.FileExtendName)" ms-attr-src="/View_Mobile/Images/qywd/{{el.FileExtendName}}.png" onerror="javascript: this.src = '/View_Mobile/Images/qywd/file.png'" />
                        </div>
                        <div class="item-inner" style="height:40px">
                            <div class="item-title" ms-on-tap="viewwxx(el)">{{el.Name}}.{{el.FileExtendName}}</div>
                            <div class="item-after" style="">
                                <a ms-attr-href="'/ViewV5/Base/DownFile.aspx?MD5='+el.FileMD5" class="external">
                                    <img style="height:20px;width:20px;float:right;" src="../Images/down.png" />
                                </a>
                            </div>
                        </div>
                    </li>
                </ul>
            </div>
        </div>
    </div>
    <script type='text/javascript' src='//g.alicdn.com/sj/lib/zepto/zepto.min.js' charset='utf-8'></script>
    <script type='text/javascript' src='//g.alicdn.com/msui/sm/0.5.8/js/sm.min.js' charset='utf-8'></script>
    <script type='text/javascript' src='//g.alicdn.com/msui/sm/0.5.8/js/sm-extend.min.js' charset='utf-8'></script>
    <script src="/View_Mobile/JS/avalon.mobile.min.js"></script>
    <script src="/View_Mobile/JS/ComFunJS.js?jsver=20160425"></script>
    <script>
        var strId = ComFunJS.getQueryString("id");
        var strname = ComFunJS.getQueryString("name");
        var strType = ComFunJS.getQueryString("type");

        //document.addEventListener('WeixinJSBridgeReady', function onBridgeReady() {
        //    //隐藏右上角按钮
        //    WeixinJSBridge.call('hideOptionMenu');
        //});

        window.localStorage.removeItem("page");
        window.localStorage.setItem("page", 1);

        window.localStorage.removeItem("isjz");
        window.localStorage.setItem("isjz", 0);

        var model = avalon.define({
            $id: "wdlist",
            wjjData: [],
            wjData: [],
            isback: "",
            urlData: [],
            wjjpath: "",
            no: "",
            isadd: "",
            type:"",
            Name: strname,
            fdtp: function (obj) {
                var str = $(obj).attr("urlid");
                if (!str) {

                    $(".mall_pcp").each(function (index, ele) {
                        if ($(ele).attr("src")) {
                            $(ele).attr("urlid", model.urlData.length);
                            model.urlData.push($(ele).attr("src"));
                        }
                    });
                    myPhotoBrowserCaptions = $.photoBrowser({
                        photos: model.urlData,
                        theme: 'dark'
                    });
                }

                myPhotoBrowserCaptions.open($(obj).attr("urlid") * 1);
            },
            vieww: function (el) {
                window.location = "UI_QYWD_LIST.html?id=" + el.ID + "&name=" + model.Name + "," + el.Name + "_" + el.ID + "&type=" + strType + "&r=" + Math.random();
            },
            viewwxx: function (el) {
                if (el.YLUrl) {
                    window.location = el.YLUrl;
                }
            }
        });

        function loadMore() {
            $.getJSON("/API/VIEWAPI.ashx?Action=QYWD_GETLISTDATA&r=" + Math.random(), { P1: strId == "0" ? "" : strId, itemtype: strType }, function (r) {

                if (r.ErrorMsg == "") {
                    model.wjjData.pushArray(r.Result);
                    model.wjData.pushArray(r.Result1);
                    if (model.wjjData.length == 0 && model.wjData.length == 0) {
                        model.no = "Y";
                    }
                    if (r.Result2) {
                        model.isadd = r.Result2;
                    }
                }
            })

        }

        var myPhotoBrowserCaptions;

        avalon.ready(function () {
            if (!strId) {
                strId = "1";
                strType = "1";
            }
            else {
                if (strId == "1" || strId == "2" || strId == "0") {
                    model.isback = "";
                }
                else {
                    model.isback = "Y";
                }
            }
            if (!strname) {
                model.Name = "企业知识库_1";
                if (strId == "2") {
                    model.Name = "个人文档_2";
                }
                else if (strId == "0") {
                    model.Name = "我的收藏_0";
                }
            }
            if (model.Name) {
                var html = "";
                var name = "";
                var paths = model.Name.split(',');
                $(paths).each(function (index, ele) {
                    if (!name) { name = ele; }
                    else { name = name + "," + ele; }
                    var wjj = ele.split('_');
                    var url = 'UI_QYWD_LIST.html?r=' + Math.random() + "&id=" + wjj[1] + "&type=" + strType + "&name=" + name;
                    html = html + '<a class="external" style="padding:3px;font-size:12px;" href="' + url + '">' + wjj[0] + '</a><span style="padding:3px;font-size:12px;" class="icon icon-right"></span>';
                })
                $("#path").append(html);
            }

            //$(".menu").removeClass("cura");
            //$(".menu").eq(strType * 1).addClass("cura");
            $(".tab-item").removeClass("active");
            $(".tab-item").eq(strType * 1-1).addClass("active");

            model.type = strType;

            loadMore();
        })
        function tzurl(str) {
            switch (str) {
                case 1: window.location = '/View_Mobile/UI/UI_QYWD_LIST.html?r=' + Math.random() + "&id=1&type=1"; break;//个人文档
                case 2: window.location = '/View_Mobile/UI/UI_QYWD_LIST.html?r=' + Math.random() + "&id=2&type=2"; break;//企业知识库
                case 3: window.location = '/View_Mobile/UI/UI_QYWD_LIST.html?r=' + Math.random() + "&id=0&type=3"; break;//我的收藏
                default: break;
            }
        }
        function scwj() {
            if (strId == "0") {
                ComFunJS.winwarning("我的收藏不能上传文件！");
            }
            else if (model.type == '2' || (model.type == '1' && model.isadd == 'true')) {
                $("#file").trigger("click");
                $("#file").trigger("click");
            }
            else {
                ComFunJS.winwarning("您没有上传权限！");
            }
        }
        function UploadLoad() {
            var str = strId;
            if (document.getElementById("file").files.length > 0) {
                var formData = new FormData();
                formData.append("upFile", document.getElementById("file").files[0]);
                $.ajax({
                    url: "/API/VIEWAPI.ashx?ACTION=XTGL_UPLOADFILES&P1=" + str + "&r=" + Math.random(),
                    type: "POST",
                    data: formData,
                    /**
                    *必须false才会自动加上正确的Content-Type
                    */
                    contentType: false,
                    /**
                    * 必须false才会避开jQuery对 formdata 的默认处理
                    * XMLHttpRequest会对 formdata 进行正确的处理
                    */
                    processData: false,
                    success: function (result) {
                        var r = $.parseJSON(result);
                        if (r.ErrorMsg == "") {
                            document.getElementById("file").outerHTML = document.getElementById("file").outerHTML;
                            $("#file").change(function () {
                                UploadLoad(str);
                            });
                            if (r.Result1.length == 0) {
                                model.wjData.push(r.Result[0]);
                            }
                            ComFunJS.winsuccess("上传成功！");
                        }
                    }
                });
            }
        }
    </script>
</body>







</html>
